package com.hueydink.rhythmrouletteserver;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

public class MainWindow {

	public Display display;
	public StyledText styledText;
	public MainWindow window;
	public Server server;
	public static int portNumber;

	public static void main(String[] args) {
		System.out.println("args[0] == " + args[0]);
		portNumber = Integer.parseInt(args[0]);

		try {
			MainWindow window = new MainWindow();
			window.window = window;
			window.server = new Server(window);
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void open() {
		display = Display.getDefault();
		Shell shlRhythmRouletteServer = new Shell();
		shlRhythmRouletteServer.setImage(SWTResourceManager.getImage(
				MainWindow.class,
				"/com/hueydink/rhythmrouletteserver/RR_Logo_1.png"));
		shlRhythmRouletteServer.setSize(1186, 744);
		shlRhythmRouletteServer.setText("Rhythm Roulette Server 1.0");

		Composite composite = new Composite(shlRhythmRouletteServer,
				SWT.V_SCROLL);
		composite.setBounds(0, 0, 1168, 699);

		styledText = new StyledText(composite, SWT.BORDER);
		styledText.setLocation(0, 0);
		styledText.setSize(1168, 699);
		styledText.setSelectionForeground(SWTResourceManager.getColor(255, 255,
				255));
		styledText.setSelectionBackground(SWTResourceManager.getColor(51, 51,
				51));
		styledText.setForeground(SWTResourceManager.getColor(144, 238, 144));
		styledText.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		styledText.setMarginColor(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		styledText.setBottomMargin(10);
		styledText.setLeftMargin(10);
		styledText.setRightMargin(10);
		styledText.setTopMargin(10);
		styledText.setFont(SWTResourceManager
				.getFont("Fixedsys", 9, SWT.NORMAL));
		styledText.setWordWrap(true);

		shlRhythmRouletteServer.open();
		shlRhythmRouletteServer.layout();

		while (!shlRhythmRouletteServer.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
}